package com.wh.org.controller;

import com.wh.org.pojo.Shop;
import com.wh.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class ActivationController {


    @Autowired
    private IShopService service;
    /**
     * 邮件激活
     * @param shopId
     * @param response
     */


    @GetMapping("/active/{shopId}")
    public void pass(@PathVariable Long shopId, HttpServletResponse response){
        try {
            //1new一个店铺
            Shop shop = new Shop();
            //2生成的店铺id传入
            System.err.println("3333333333333333333333333333");
            shop.setId(shopId);
            //3设置已激活状态状态
            shop.setState(3);
            System.err.println("222222222222222222222222222222");
            service.updateState(shop);
            //4跳转登录页
            System.err.println("111111111111111111111111111111111111");
            response.sendRedirect("http://127.0.0.1:8081/#/login");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
